package com.team1.supervend.domain;

public class AccountingSystemFactory {
	private static AccountingSystemFactory instance;
	public IAccountingAdapter accountingAdapter;

	public static synchronized AccountingSystemFactory getInstance()
	{
		if ( instance == null )
		{
			instance = new AccountingSystemFactory();
    	}
		return instance;
	}

	public IAccountingAdapter getAccountingAdapter() 
	{
		if ( accountingAdapter == null )
		{
			String className = System.getProperty( "accountingfirm.class.name" );
			try 
			{
				accountingAdapter = (IAccountingAdapter)Class.forName(className).newInstance();
			} 
			catch ( InstantiationException e ) 
			{
				e.printStackTrace();
		    } 
			catch ( IllegalAccessException e ) 
			{
		    	e.printStackTrace();
			} 
			catch ( ClassNotFoundException e ) 
			{
		    	e.printStackTrace();
			}
		}
		return accountingAdapter;	
	}

}
